(function (i, s, o, g, r, a, m) {
  i["GoogleAnalyticsObject"] = r;
  i[r] = i[r] || function () {
      (i[r].q = i[r].q || []).push(arguments)
    }, i[r].l = 1 * new Date;
  a = s.createElement(o), m = s.getElementsByTagName(o)[0];
  a.async = 1;
  a.src = g;
  m.parentNode.insertBefore(a, m)
})(window, document, "script", "https://www.google-analytics.com/analytics.js", "ga");
function statistics_init(user_id, referrer, page) {
  ga("create", "UA-84522826-1", "auto", {userId: user_id.toString()});
  if (referrer !== undefined) {
    ga("set", "referrer", referrer.toString())
  }
  if (page !== undefined) {
    ga("set", "page", page.toString())
  }
}
function statistics_data_plan_pay(data_plan_id, data_plan_size, data_plan_price, data_plan_carrier, callback, timeout) {
  ga("require", "ec");
  ga("set", "&cu", "CNY");
  ga("ec:addProduct", {
    id: data_plan_id.toString(),
    name: data_plan_size.toString() + "流量",
    category: "流量套餐",
    brand: data_plan_carrier.toString(),
    price: data_plan_price.toString(),
    quantity: "1"
  });
  ga("ec:setAction", "checkout", {step: 1, option: "微信支付"});
  statistics_page_view(callback, timeout)
}
function statistics_data_plan_purchase(transaction_id, data_plan_id, data_plan_size, data_plan_price, data_plan_carrier, callback, timeout) {
  ga("require", "ec");
  ga("set", "&cu", "CNY");
  ga("ec:addProduct", {
    id: data_plan_id.toString(),
    name: data_plan_size.toString() + "流量",
    category: "流量套餐",
    brand: data_plan_carrier.toString(),
    price: data_plan_price.toString(),
    quantity: "1"
  });
  ga("ec:setAction", "purchase", {
    id: transaction_id.toString(),
    affiliation: "速致商城",
    revenue: data_plan_price.toString()
  });
  statistics_page_view(callback, timeout)
}
function statistics_page_view(callback, timeout) {
  if (callback !== undefined) {
    ga("send", {hitType: "pageview", hitCallback: callback});
    if (timeout !== undefined) {
      setTimeout(callback, timeout)
    }
  } else {
    ga("send", "pageview")
  }
}
